


import * as echarts from 'echarts'
 export default {
   methods: {
     ScatterGraph_V2Init(v){
       const scatter = [
        [10.0, 8.04],
        [8.07, 6.95],
        [13.0, 7.58],
        [9.05, 8.81],
        [11.0, 8.33],
        [14.0, 7.66],
        [13.4, 6.81],
        [10.0, 6.33],
        [14.0, 8.96],
        [12.5, 6.82],
        [9.15, 7.2],
        [11.5, 7.2],
        [3.03, 4.23],
        [12.2, 7.83],
        [2.02, 4.47],
        [1.05, 3.33],
        [4.05, 4.96],
        [6.03, 7.24],
        [12.0, 6.26],
        [12.0, 8.84],
        [7.08, 5.82],
        [5.02, 5.68],
      ]

      let echartEle=  this.$refs[v];
      let myChart = echarts.init(echartEle);

      const {
        dataSourceType,options,staticData
      } = this.controlProperties[v]

      if (dataSourceType === 'static' && Object.keys(staticData).length) {
        options.series = options.series.map((item, index) => {
          return { ...item, data: staticData.series[index].data }
        })
      } else if(dataSourceType === 'static' && !Object.keys(staticData).length) {
        options.series = options.series.map((item) => {
          return { ...item, data: scatter }
       })
      }
      options && myChart.setOption(options);
     },
     ScatterGraph_V2SetOption(v){
        const { options,seriesType,flowResult } = this.controlProperties[v]
        let { series } = options
       
        // series
        series = series.map((item) => {
          item.data = flowResult[item.dataSource[item.dataSource.length - 1].dataKey]
        })
        let echartEle=  this.$refs[v];
        let myChart = echarts.init(echartEle);
        options && myChart.setOption(options);
     },
   }
  }
